/*     */ package com.jcraft.jzlib;
/*     */ 
/*     */ import java.io.FilterInputStream;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ZInputStream
/*     */   extends FilterInputStream
/*     */ {
/*  41 */   protected ZStream z = new ZStream();
/*  42 */   protected int bufsize = 512;
/*  43 */   protected int flush = 0;
/*  44 */   protected byte[] buf = new byte[this.bufsize]; protected byte[] buf1 = new byte[1];
/*     */   
/*     */   protected boolean compress;
/*  47 */   protected InputStream in = null;
/*     */   
/*     */   public ZInputStream(InputStream in) {
/*  50 */     this(in, false);
/*     */   }
/*     */   
/*     */   public ZInputStream(InputStream in, boolean nowrap) {
/*  54 */     super(in);
/*  55 */     this.in = in;
/*  56 */     this.z.inflateInit(nowrap);
/*  57 */     this.compress = false;
/*  58 */     this.z.next_in = this.buf;
/*  59 */     this.z.next_in_index = 0;
/*  60 */     this.z.avail_in = 0;
/*     */   }
/*     */   
/*     */   public ZInputStream(InputStream in, int level) {
/*  64 */     super(in);
/*  65 */     this.in = in;
/*  66 */     this.z.deflateInit(level);
/*  67 */     this.compress = true;
/*  68 */     this.z.next_in = this.buf;
/*  69 */     this.z.next_in_index = 0;
/*  70 */     this.z.avail_in = 0;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public int read()
/*     */     throws IOException
/*     */   {
/*  79 */     if (read(this.buf1, 0, 1) == -1)
/*  80 */       return -1;
/*  81 */     return this.buf1[0] & 0xFF;
/*     */   }
/*     */   
/*  84 */   private boolean nomoreinput = false;
/*     */   
/*     */   public int read(byte[] b, int off, int len) throws IOException {
/*  87 */     if (len == 0) {
/*  88 */       return 0;
/*     */     }
/*  90 */     this.z.next_out = b;
/*  91 */     this.z.next_out_index = off;
/*  92 */     this.z.avail_out = len;
/*     */     int err;
/*  94 */     do { if ((this.z.avail_in == 0) && (!this.nomoreinput))
/*     */       {
/*     */ 
/*  97 */         this.z.next_in_index = 0;
/*  98 */         this.z.avail_in = this.in.read(this.buf, 0, this.bufsize);
/*     */         
/*     */ 
/* 101 */         if (this.z.avail_in == -1) {
/* 102 */           this.z.avail_in = 0;
/* 103 */           this.nomoreinput = true;
/*     */         } }
/*     */       int err;
/* 106 */       if (this.compress) {
/* 107 */         err = this.z.deflate(this.flush);
/*     */       } else
/* 109 */         err = this.z.inflate(this.flush);
/* 110 */       if ((this.nomoreinput) && (err == -5))
/* 111 */         return -1;
/* 112 */       if ((err != 0) && (err != 1))
/* 113 */         throw new ZStreamException((this.compress ? "de" : "in") + 
/* 114 */           "flating: " + this.z.msg);
/* 115 */       if (((this.nomoreinput) || (err == 1)) && 
/* 116 */         (this.z.avail_out == len))
/* 117 */         return -1;
/* 118 */     } while ((this.z.avail_out == len) && (err == 0));
/*     */     
/* 120 */     return len - this.z.avail_out;
/*     */   }
/*     */   
/*     */   public long skip(long n) throws IOException {
/* 124 */     int len = 512;
/* 125 */     if (n < len)
/* 126 */       len = (int)n;
/* 127 */     byte[] tmp = new byte[len];
/* 128 */     return read(tmp);
/*     */   }
/*     */   
/*     */   public int getFlushMode() {
/* 132 */     return this.flush;
/*     */   }
/*     */   
/*     */   public void setFlushMode(int flush) {
/* 136 */     this.flush = flush;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public long getTotalIn()
/*     */   {
/* 143 */     return this.z.total_in;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public long getTotalOut()
/*     */   {
/* 150 */     return this.z.total_out;
/*     */   }
/*     */   
/*     */   public void close() throws IOException {
/* 154 */     this.in.close();
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\com\jcraft\jzlib\ZInputStream.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */